package be.atc.phh.dao;

import be.atc.antoine.beans.Local;
import be.atc.antoine.beans.Materiel;
import be.atc.antoine.beans.UF;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;
import org.apache.log4j.Logger;
import be.atc.connection.ConnectionDB;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import be.atc.connection.DBConnection;


public class DaoUFImpl implements DaoUF{
	
	private static final Logger log = Logger.getLogger(DaoUFImpl.class);

	
	public List<UF> recupAllUF(){
		List<UF> retour= new ArrayList<UF>();
		Connection con;
		CallableStatement stmt;
		String qr = "Select Code_UF, Nom_UF from uf";
		con=DBConnection.getInstance();
		if(con!=null)
		{
			try{
			stmt=con.prepareCall(qr);
			ResultSet rs=stmt.executeQuery();
			while(rs.next()){
				UF temp=new UF();
				temp.setCode_uf(rs.getString("Code_UF"));
				//System.out.println(temp.getCode_uf());
				temp.setNomUF(rs.getString("Nom_UF"));
				retour.add(temp);
			}
			DBConnection.closeAll(rs, stmt);
			DBConnection.closeConnection();
			}catch(SQLException e){
				log.error("Erreur SQL recupAllUF:"+e);
			}
		}	
		return retour;
		
	}

}
